'use strict';
const path = require('path')
module.exports = appInfo => {
  const config = exports = {};
   //小程序appid
   config.appId = 'wxd4d051abe6454189';
   config.appSecret = 'c63f06cf77dd298758b0ba218db9e72c';


   // use for cookie sign key, should change to your own and keep security
   config.keys = appInfo.name + '_1522421759858_6994';

  // add your config here
  config.middleware = [];
  // add your config here
  config.static = {
    prefix: '/',
    dir: path.join(__dirname, '../', 'public'),
    maxAge: 315360000000,
  };
  // add your config here
  config.mongoose = {
    url: 'mongodb://root:18786700454@119.23.75.91:27017/cmi',
    // url: 'mongodb://root:18786700454@127.0.0.1:27017/cmi',
    options: {}
  }

  config.session = {
    key: 'EGG_SESS',
    // 86400
    maxAge: 1 * 3600 * 1000, // 1 天
    httpOnly: true,
    encrypt: true,
  };

  config.security = {
    xframe: {
      value: 'X-Frame-Options: sameorigin'
    },
    csrf: {
      enable: false,
      ignore: '/recharge/get',
      // ignore: '/super/getimg',
      ignoreJSON: true,
      queryName: '_csrf', // 通过 query 传递 CSRF token 的默认字段为 _csrf
      bodyName: '_csrf', // 通过 body 传递 CSRF token 的默认字段为 _csrf
      headerName: 'x-csrf-token',
    },
    domainWhiteList: ['www.yzema.cn', 'open.weixin.qq.com', '127.0.0.1'],
  };

  const whitelist = [
    // images
    '.jpg', '.jpeg', // image/jpeg
    '.png', // image/png, image/x-png
    '.gif', // image/gif
    '.bmp', // image/bmp
    '.wbmp', // image/vnd.wap.wbmp
    '.webp',
    '.tif',
    '.psd',

    // text
    '.svg',
    '.js', '.jsx',
    '.json',
    '.css', '.less',
    '.html', '.htm',
    '.xml',
    '.txt',
    // tar
    '.zip',
    '.gz', '.tgz', '.gzip',
    // video
    '.mp3',
    '.mp4',
    '.avi',
  ];

  config.multipart = {
    fileSize: '1mb',
    whitelist: whitelist
  };
  config.oss = {
    client: {
      accessKeyId: 'LTAI5HipatGArnCo',
      accessKeySecret: 'NZlPIcUz9vTkTWycujEgD8txrZz8rE',
      bucket: 'diarymoon',
      endpoint: 'oss-cn-shenzhen.aliyuncs.com',
      timeout: '60s',
    },
  };
  // config.passportGithub = {
  //   key: 'a',
  //   secret: 'b',
  //   // callbackURL: '/passport/github/callback',
  //   // proxy: false,
  // };
  // config.io = {
  //   init: { }, // passed to engine.io
  //   namespace: {
  //     '/': {
  //       connectionMiddleware: ['auth'],
  //       packetMiddleware: ['filter'],
  //     },
  //     '/chat': {
  //       connectionMiddleware: ['auth'],
  //       packetMiddleware: ['filter'],
  //     },
  //   },
  // };
  return config;
};